import { httpPost, httpGet } from '@/utils/http'
import ResponseData from '@/interface/aboutAPI'

export interface ApiResponse {
  e: number
  total?: number
  data: ResponseData
  msg?: string
  success?: boolean
}

// 获取个人信息
export const getInformationAPI = (idno: string) => {
  return httpGet<ApiResponse>(`/v1/api/open/emp/profile/${idno}`, { idno })
}

/**
 * 更新基本信息到后端
 * @param edugrade - 学历
 * @param adress - 居住地
 * @param nativeplace - 户籍地
 * @param idnumber - 身份证号码
 * @param cell - 手机号
 * @param name - 姓名
 * @param birthday - 生日
 * @param gender - 性别
 */

// 更新基本信息接口
export const updateBasicInformationAPI = (params: any, idno: string) => {
  const {
    edugrade,
    address,
    nativeplace,
    idnumber,
    cell,
    name,
    birthday,
    gender,
    vendor = 'v1',
  } = params
  return httpPost(`/v1/api/open/emp/updbasic/${idno}`, {
    edugrade,
    address,
    nativeplace,
    vendor,
    idnumber,
    cell,
    name,
    birthday,
    gender,
  })
}

// 教育信息接口
export const postEduInformationAPI = (group: string, idno: string, eductions: any[]) => {
  return httpPost(`/v1/api/open/emp/update/${group}/${idno}`, eductions)
}
// 工作经历接口
export const postWorkExperienceAPI = (group: string, idno: string, joblist: any[]) => {
  console.log('joblist', joblist)
  return httpPost(`/v1/api/open/emp/update/${group}/${idno}`, joblist)
}

// 家庭详情接口
export const postFamilyDetailsAPI = (group: string, idno: string, relativelist: any[]) => {
  return httpPost(`/v1/api/open/emp/update/${group}/${idno}`, relativelist)
}

// 上传头像接口
export const postProfilePictureAPI = (idno, base64Image) => {
  return httpPost(`/v1/api/open/emp/updavtar/${idno}`, { image: base64Image })
}
